package lbframework.bean.textField;

import java.beans.*;

public class LBTextFieldBeanInfo extends SimpleBeanInfo {

    private final static Class beanClass = LBTextField.class;
    private static BeanDescriptor beanDescriptor = null;
    private static java.awt.Image icon = null;

    @Override
    public BeanDescriptor getBeanDescriptor() {
        beanDescriptor = new BeanDescriptor(beanClass);
        beanDescriptor.setDisplayName("LB TextField");

        return beanDescriptor;
    }

    @Override
    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            PropertyDescriptor mascaraPD = new PropertyDescriptor("mascara", beanClass);
            PropertyDescriptor columnsPD = new PropertyDescriptor("columns", beanClass);
            PropertyDescriptor caixaAltaPD = new PropertyDescriptor("caixaAlta", beanClass);
            PropertyDescriptor selecionaTextoPD = new PropertyDescriptor("selecionaTexto", beanClass);
            PropertyDescriptor negativoPD = new PropertyDescriptor("negativo", beanClass);
            PropertyDescriptor teclaEnterPD = new PropertyDescriptor("teclaEnter", beanClass);
            PropertyDescriptor obrigatorio = new PropertyDescriptor("obrigatorio", beanClass);

            PropertyDescriptor rv[] = {caixaAltaPD, mascaraPD, columnsPD, selecionaTextoPD, negativoPD, teclaEnterPD, obrigatorio};

            mascaraPD.setPropertyEditorClass(MascaraPropertyEditor.class);

            return rv;

        } catch (IntrospectionException e) {
            throw new Error(e.toString());
        }
    }

    @Override
    public BeanInfo[] getAdditionalBeanInfo() {
        Class superclass = LBTextField.class.getSuperclass();

        try {
            BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);

            return new BeanInfo[]{superBeanInfo};

        } catch (IntrospectionException ex) {
            ex.printStackTrace();
            return null;
        }
    }

    @Override
    public java.awt.Image getIcon(int iconKind) {
        if (iconKind == ICON_COLOR_16x16 || iconKind == ICON_MONO_16x16) {
            icon = loadImage("textField16.png");
        } else if (iconKind == ICON_COLOR_32x32 || iconKind == ICON_MONO_32x32) {
            icon = loadImage("textField32.png");
        } else {
            icon = null;
        }

        return icon;
    }
}
